Page({
data:{
  list:[],
  isShow:false,
  current:'1',
  pageSize:'3',
  total:0,
  refreshers:true
},
onLoad(){
this.getList()
},
//获取基本数据
  async getList(){
    wx.showToast()
  const {code,data:{rows:list,total}} = await wx.http.get('/repair',{
    current:this.data.current,
    pageSize:this.data.pageSize
  })
  if(code!==10000) return wx.utils.toast()
  this.setData({
    list:[...this.data.list,...list],
    isShow:list.length === 0,
    total
  })
//更新一下cur的值，下次掉接口就是第二页
if(+this.data.current <total){
  this.setData({
    current:+this.data.current+1
  })
}

  wx.hideToast()
},
//触底刷新
nextList(){
  // console.log(11);
  if(this.data.total > this.data.list.length) {
   this.getList()
  }
},
//下拉刷新
refresherList(){
  console.log(1);
  //数据还原，开始刷新
  this.setData({
    list:[],
    isShow:false,
    current:'1',
    pageSize:'3',
    total:0,
  })
  this.getList()
  this.setData({refreshers:false})
},

  goDetail(ev) {
    // console.log(ev);
    wx.navigateTo({
      url: '/repair_pkg/pages/detail/index?id='+ev.mark.id,
    })
  },
  addRepair() {
    wx.navigateTo({
      url: '/repair_pkg/pages/form/index',
    })
  },
})
